package tool;

import java.util.Arrays;

/**
 * @Author zzz
 * @Date 2022/1/8 9:51
 * @Version 1.0
 */
public class generateNums {
    public static int[] generate(int maxSize,int maxNum){
        int n = (int)(Math.random()*maxSize);
        int[] res = new int[n];
        for (int i = 0; i < n; i++) {
            int temp = (int) (Math.random()*maxNum- Math.random()*maxNum);
            res[i] = temp;
        }
        return res;
    }

    public static int[] generatePositiveNums(int maxSize, int maxNum){
        int n = (int)(Math.random()*maxSize);
        int[] res = new int[n];
        for (int i = 0; i < n; i++) {
            res[i] = (int)(Math.random()*maxNum)+1;
        }
        return res;
    }

    public static int[] generateSorted(int maxSize,int maxNum){
        int n = (int)(Math.random()*maxSize);
        int[] res = new int[n];
        for (int i = 0; i < n; i++) {
            int temp = (int) (Math.random()*maxNum- Math.random()*maxNum);
            res[i] = temp;
        }
        Arrays.sort(res);
        return res;
    }
    public static int[] generatePositiveNumsSorted(int maxSize, int maxNum){
        int n = (int)(Math.random()*maxSize);
        int[] res = new int[n];
        for (int i = 0; i < n; i++) {
            res[i] = (int)(Math.random()*maxNum);;
        }
        Arrays.sort(res);
        return res;
    }
}
